package com.ulife.order.components;

import com.sun.prism.ReadbackRenderTarget;
import com.ulife.base.entities.order.SaleOrderCriteria;
import com.ulife.base.entities.order.SaleOrderRefund;
import com.ulife.base.entities.order.SaleOrderRefundCriteria;
import com.ulife.base.logics.order.SaleOrderLogic;
import com.ulife.base.logics.order.SaleOrderRefundLogic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import  com.ulife.order.api.response.cms.SaleOrderRefundInfo;

import java.util.ArrayList;
import  java.util.List;

/**
 * Created by Luohx on 2016/6/16.
 */
@Component
public class OrderBusiness {

    @Autowired
    private SaleOrderLogic saleOrderLogic;

    @Autowired
    private SaleOrderRefundLogic saleOrderRefundLogic;

    /**
     *  校验订单是否存在
     * @param order_no 订单编号
     * @return true:存在订单；<br />false：不存在此订单；
     */
//    public boolean isOrderExist(String order_no){
//        SaleOrderCriteria criteria = new SaleOrderCriteria();
//        criteria.createCriteria().andSaleNoEqualTo(order_no);
//        int count = saleOrderLogic.count(criteria);
//        if(count > 0)
//            return  true;
//        else
//            return  false;
//    }

    /**
     *  查询订单退款记录
     * @param order_no 订单编号
     * @return 订单退款列表
     */
//    public List<SaleOrderRefundInfo> getSaleRefundInfos(String order_no){
//        SaleOrderRefundCriteria criteria = new SaleOrderRefundCriteria();
//        criteria.createCriteria().andSoNoEqualTo(order_no);
//
//        java.util.List<SaleOrderRefund> list = this.saleOrderRefundLogic.list(criteria);
//
//        List<SaleOrderRefundInfo> result = this.saleOrderRefundInfoMapping(list);
//        return  result;
//    }

    /**
     *  映射封装订单退款记录
     * @param refundItems 原始订单退款记录
     * @return
     */
//    private  List<SaleOrderRefundInfo> saleOrderRefundInfoMapping(java.util.List<SaleOrderRefund> refundItems){
//        List<SaleOrderRefundInfo> result = new ArrayList<SaleOrderRefundInfo>();
//        for (SaleOrderRefund item : refundItems){
//            SaleOrderRefundInfo info = new SaleOrderRefundInfo();
//            info.setAmount(item.getAmount().doubleValue());
//            info.setModifiedBy(item.getModifiedBy());
//            info.setModifiedBy(item.getModifiedBy());
//            info.setCreatedTime(item.getCreatedTime().getTime());
//            info.setModifiedTime(item.getModifiedTime().getTime());
//            info.setPayChannel(item.getPayChannel());
//            info.setPayId(item.getPayId());
//            info.setSoNo(item.getSoNo());
//            result.add(info);
//        }
//        return result;
//    }
}
